package com.danbai.ys.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: dbys
 * @description: Swagger2Config
 * @author: DanBai
 * @create: 2020-06-28 14:56
 **/
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .host("dbys.vip")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.danbai.ys.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("淡白影视API文档")
                .description("淡白影视的API接口文档")
                .termsOfServiceUrl("https://dbys.vip")
                .version("1.0")
                .contact(new Contact("淡白",
                        "https://p00q.cn/",
                        "db225@qq.com"))
                .build();
    }
}
